update platform 8

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...

...

... back to index page OE documentation



RECT_BOTTOM = 12, RECT_SIZEOF = 16

atom rect = allocate(RECT_SIZEOF)

poke4(rect + RECT_LEFT, 10) poke4(rect + RECT_TOP, 20) poke4(rect + RECT_RIGHT, 90) poke4(rect + RECT_BOTTOM, 100)

pass rect as a pointer to a C structure

hWnd is a "handle" to the window if not c_func(InvalidateRect, {hWnd, rect, 1}) then puts(2, "InvalidateRect failed\n") end if </eucode>

The Euphoria code that accesses C routines and data structures may look a bit ugly, but it will typically form just a small part of your program, especially if you use Win32Lib, EuWinGUI, or Irv Mullin's X Windows library. Most of your program will be written in pure Euphoria, which will give you a big advantage over those forced to code in C.

Call-backs to your Euphoria routines

When you create a window, the Windows operating system will need to call your Euphoria routine. To set this up, you must get a 32-bit "call-back" address for your routine and give it to Windows. For example (taken from demo\win32\window.exw):

integer id 
atom WndProcAddress 
 
id = routine_id("WndProc") 
 
WndProcAddress = call_back(id) 

routine_id uniquely identifies a Euphoria procedure or function by returning an integer value. This value can be used later to call the routine. You can also use it as an argument to the call_back function.

In the example above, The 32-bit call-back address, WndProcAddress, can be stored in a C structure and passed to Windows via the RegisterClass() C API function.
This gives Windows the ability to call the Euphoria routine, WndProc(), whenever the user performs an action on a certain class of window. Actions include clicking the mouse, typing a key, resizing the window etc.
See the window.exw demo program for the whole story.

Note:
It is possible to get a call-back address for any Euphoria routine that meets the following conditions: * the routine must be a function, not a procedure * it must have from 0 to 9 parameters * the parameters should all be of type atom (or integer etc.), not sequence * the return value should be an integer value up to 32-bits in size
You can create as many call-back addresses as you like, but you should not call call_back for the same Euphoria routine multiple times - each call-back address that you create requires a small block of memory.

The values that are passed to your Euphoria routine can be any 32-bit unsigned atoms, i.e. non-negative. Your routine could choose to interpret large positive numbers as negative if that is desirable. For instance, if a C routine tried to pass you -1, it would appear as hex FFFFFFFF.

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu